<?php
class OvirsController extends AppController {

	var $name = 'Ovirs';

	function index() {
	$this->loadModel('Profession');
	$this->loadModel('Learningform');
	$this->loadModel('Learningtype');
	$this->loadModel('Studentgroup');
		if ($this->request->is('post')) {
			$this->Studentgroup->create();
			if ($this->Studentgroup->save($this->request->data)) {
				$this->Session->setFlash(__('The studentgroup has been saved'));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The studentgroup could not be saved. Please, try again.'));
			}
		}
		$professions = $this->Studentgroup->Course->Profession->find('list');
	//	$courses = $this->Studentgroup->Course->find('list');
		$learningforms = $this->Studentgroup->Learningform->find('list');
		$learningtypes = $this->Studentgroup->Learningtype->find('list');
		$this->set(compact('professions', 'learningforms', 'learningtypes'));
	}
	
    public function update_course () {
 		if(!empty($this->data['Studentgroup']['profession_id'])) {
			$profession_id = $this->data['Studentgroup']['profession_id'];
			$this->loadModel('Course');
			$options = $this->Course->find('list'  , array('conditions' => array ('Course.profession_id' => $profession_id)));
			$this->set(compact('options'));
			$this->render('update_course', 'blank');
		} 
	}
}
?>